<?php
/**
 * Template Name: Location Main Template
 * Description: This is the main page for LinkUp by Location
 *
 * @since admired 1.0
 */

get_header(); ?>

		<div id="primary">
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js "></script>
		<script src="<?php bloginfo('stylesheet_directory'); ?>/javascript/cityselect.js"></script>
			<div id="content" role="main">

				<?php  while ( have_posts() ) : 
						the_post();
						get_template_part( 'loop', 'page' ); //get the code from loop-page.php
						//comments_template( '', true ); //get the code from '' (default file = comments.php)

				 endwhile; // end of the loop.?>
				 
				
				<h3 align="left">Select your location below</h3>
				<form name="frmMain">
					<div id="choose_state">
						Select a state: <select name="states" onChange="populate_Cities()">
							<option selected="selected">Choose a state</option>
				<?php
                                echo "\n";
                                $states=$GLOBALS[wpdb]->get_col(
                                            "
                                                SELECT distinct description 
                                                FROM wp_bp_groups 
                                                WHERE status='public'
												ORDER BY description
                                            ");                        
                                    foreach ($states as $value) {
                                        echo "<option value=$value>$value</option>\n";
                                    };
                                ?>
							
						</select>
					</div><!--choose_state -->
					
				</form>
				

				<script>
				function go_city(){
				var citiesList = document.frmMain.cities;
				var cityValue = citiesList[citiesList.selectedIndex].value;
				window.location="<?php bloginfo('url');?>/groups/"+cityValue;
				}
				</script>
				
				
			</div><!-- #content -->
		</div><!-- #primary -->

<?php 
		get_sidebar();
		get_footer(); ?>